package track2;

public class MyRunnable implements Runnable{

    static int peasant=100;

    @Override
    public void run() {
        while (true){
            synchronized (MyRunnable.class){
                try {
                    Thread.sleep(30);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                peasant--;
                if (peasant<10){
                    break;
                }
                System.out.println(Thread.currentThread().getName()+"还剩"+peasant+"份礼物");
            }
        }
    }
}
